package me.zhengjie.modules.quartz.task.pull;

import lombok.extern.slf4j.Slf4j;
import me.zhengjie.modules.quartz.service.dto.SyncCommon;
import me.zhengjie.modules.sync.pull.DeptSync;
import me.zhengjie.modules.sync.pull.EmpSync;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;

@Slf4j
@Component
public class OrganizationPullTask extends PullTaskBase {

    @Autowired
    private DeptSync deptSync;
    @Autowired
    private EmpSync empSync;

    public OrganizationPullTask() {
        setTaskName(this.getClass().getSimpleName());
    }

    @Override
    protected void pull(SyncCommon syncCommon, Date dynamicDate) {
        //部门
        log.info("run companyUuid {} deptSync start ",syncCommon.getCompanyUuid());
        Long startTime=System.currentTimeMillis();
        deptSync.pull(syncCommon, dynamicDate);
        Long endTime=System.currentTimeMillis();
        log.info("run companyUuid {} deptSync end {} ",syncCommon.getCompanyUuid(),(endTime-startTime));

        //经纪人
        log.info("run companyUuid {} empSync start ",syncCommon.getCompanyUuid());
        startTime=System.currentTimeMillis();
        empSync.pull(syncCommon, dynamicDate);
        endTime=System.currentTimeMillis();
        log.info("run companyUuid {} empSync end {} ",syncCommon.getCompanyUuid(),(endTime-startTime));
    }
}
